#ifndef FILEWIDGET_H
#define FILEWIDGET_H

#include <QWidget>
#include "mytypes.h"
#include <QStandardItemModel>
#include <QGridLayout>
#include <QTableView>
#include <QPlainTextEdit>
#include <QTabWidget>
#include <QVBoxLayout>
#include <QSpacerItem>
#include <QComboBox>
#include <QLabel>
#include <QMenu>
#include <QAction>
#include <QModelIndex>
#include <QStringList>
#include <mutex>
namespace Ui {
class FileWidget;
}

class FileWidget : public QWidget
{
    Q_OBJECT

public:
    static const QStringList FilePwLevel;
    static const QStringList IllegaLevel;

    explicit FileWidget(QWidget *parent = nullptr);
    ~FileWidget();

    void Init_Ui();

    void SetCurWidget(Yzty::MODECODE code);
    void Init_Config(QMap<int,QVector<QPair<QString,QStringList>>>& pstruct);
    void UpdateData(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);

    void ClearModel(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);
    void ClearAllModel();
    void UpDatecnts();
public slots:
    void doMouseTrackTip(QModelIndex index);
private:

    void UpDateFTotal(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);
    void UpDateFKey(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);
    void UpDateFDoubt(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);
    void UpDateFOther(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);
    void UpDateFIllegal(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);
    
    void UpDatePTotal(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);
    void UpDatePKey(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);
    void UpDatePDoubt(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);
    void UpDatePOther(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);
    void UpDatePIllegal(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);
    
    void UpDateFileOpRecord(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);
    void UpDateFilePw(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);
    void UpDateFileExtern(Yzty::MODECODE code,Yzty::ITEMCODE tcode=0);

public slots:
    void MouseRightMenu(const QPoint& pos);
    void KeyWord_Combox_Change(int pi,int pj);
private slots:
    void OpenFile();
    void OpenFileLocation();
    void RowSelect_Paint(int row,int i,int j);
    void Judge(QAction*);
    void LevelJudge(int i);

private:
    std::mutex                              _updatemutex;

    Ui::FileWidget *ui;
    QVector<QVector<QStandardItemModel*>>   _models;
    QVector<QVector<QTableView*>>           _views;
    QVector<QVector<QPlainTextEdit*>>       _plains;
    QVector<QVector<QStringList>>           _model_labels;
    QVector<QVector<QComboBox*>>            _comboxs;
    QList<QTabWidget*>                      _tabws;

    QMenu*                                  _tableviewmenu;
    QAction*                                _openfile;
    QAction*                                _openfilelocation;
    QModelIndex                             curindex;
    QMenu*                                  _plevelmenu;  //密级判定
    QVector<QAction*>                       _plevel;
    QVector<QVector<QLabel*>>               _numbers;//"扫描文件数，检查文件数，命中文件数"
};

#endif // FILEWIDGET_H
